package com.xatu.ego.myfaq.controller;

import com.github.pagehelper.PageHelper;
import com.xatu.ego.myfaq.config.PageHelperConfig;
import com.xatu.ego.myfaq.model.SysUser;
import com.xatu.ego.myfaq.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping(value = "/user")
public class UsersController {
    @Autowired
    private UserService userService;

    @ResponseBody
    @PostMapping("/add")
    public int addUser(SysUser user){
        return userService.addUser(user);
    }

    @ResponseBody
    @GetMapping("/all")
    public Object findAllUser(
            @RequestParam(name = "pageNum", required = false, defaultValue = "1")
                    int pageNum,
            @RequestParam(name = "pageSize", required = false, defaultValue = "100")
                    int pageSize){

        List<SysUser> users = userService.findAllUser(pageNum,pageSize);
        int count = userService.countAll();
        return users;
    }



}
